import java.net.*;
import java.io.*;


public class ProxyServer {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		int port = 9090;
		ProxyServer server= new ProxyServer(port);
		server.run();
		server.tearDown();
	}

	ServerSocket serverSocket;//Listen for TCP connection request. need to chang to UDT later.
	
	ObjectInputStream readFromClient;
	ObjectOutputStream writeToClient;
	
	public ProxyServer(int port) throws IOException{
		serverSocket = new ServerSocket(port);		
	}
	public void run(){
		try {
			Socket newClient = serverSocket.accept();
			
			readFromClient = new ObjectInputStream( newClient.getInputStream() );
			writeToClient = new ObjectOutputStream( newClient.getOutputStream() );
			
			writeToClient.writeUTF("Welcome to Connect to Server 008");
			
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}		
	}
	public void tearDown() throws IOException{
		readFromClient.close();
		writeToClient.close();
		serverSocket.close();		
	}
}
